// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  let { nickName,_openid } = event
  var success = false
  var message = "修改昵称失败"
  var resp = {}
  const db = cloud.database()
  

  var updeteResp = await db.collection('user').where({
    _openid: _openid
  }).update({
    data: {
      isOut: true,
    }
  }).then(res => {
    console.log("update:", nickName)
    success = true
    message = "淘汰队员成功"
    resp = {
      nickName: nickName
    }
  }, error => {
    success = false
    message = "淘汰队员失败"
  })
  return {
    success: success,
    message: message,
    data: resp
  }
}